DROP VIEW [dbo].[vi0124]
GO
CREATE VIEW [dbo].[vi0124] AS 
Select 
	tb0054.InventoryID, tb0054.DivisionID, 
	tb0054.S1, tb0062_S1.SName as SName1,
  	tb0054.S2, tb0062_S2.SName as SName2,
	tb0054.S3, tb0062_S3.SName as SName3,
	tb0054.InventoryName, 
	tb0054.InventoryTypeID, tb0053.InventoryTypeName ,
	tb0054.UnitID, tb0056.UnitName ,
	Varchar01, Varchar02,
	tb0054.Disabled, tb0054.CreateDate, tb0054.CreateUserID, tb0054.LastModifyDate, tb0054.LastModifyUserID, 
	MethodID, IsSource, 
	AccountID, SalesAccountID, PurchaseAccountID, PrimeCostAccountID, 
	IsLimitDate, IsLocation, IsStocked, VATGroupID, VATPercent, NormMethod, 
	I01ID, tb0033_I01.AnaName  as AnaName1,
	I02ID, tb0033_I02.AnaName  as AnaName2,
	I03ID, tb0033_I03.AnaName  as AnaName3,
	I04ID, tb0033_I04.AnaName  as AnaName4,
	I05ID, tb0033_I05.AnaName  as AnaName5,
	Notes01, Notes02, Notes03, 
	Specification1,Specification2,Specification3,Specification4,Specification5,
	IsTools, IsKIT, KITID, RefInventoryID, tb0054.BarcodeID,
	tb0054.GroupShow
   
From tb0054 	Left Join tb0056 On tb0054.UnitID = tb0056.UnitID
		Left Join tb0053 On tb0054.InventoryTypeID = tb0053.InventoryTypeID
		Left Join tb0062 tb0062_S1 On tb0054.S1= tb0062_S1.S and tb0062_S1.STypeID ='I01' 
		Left Join tb0062 tb0062_S2 On tb0054.S2= tb0062_S2.S and tb0062_S2.STypeID ='I02' 
		Left Join tb0062 tb0062_S3 On tb0054.S3= tb0062_S3.S and tb0062_S3.STypeID ='I03' 
		Left Join tb0033 tb0033_I01 On tb0054.I01ID= tb0033_I01.AnaID and tb0033_I01.AnaTypeID ='I01' 
		Left Join tb0033 tb0033_I02 On tb0054.I02ID= tb0033_I02.AnaID and tb0033_I02.AnaTypeID ='I02' 
		Left Join tb0033 tb0033_I03 On tb0054.I03ID= tb0033_I03.AnaID and tb0033_I03.AnaTypeID ='I03' 
		Left Join tb0033 tb0033_I04 On tb0054.I04ID= tb0033_I04.AnaID and tb0033_I04.AnaTypeID ='I04' 
		Left Join tb0033 tb0033_I05 On tb0054.I05ID= tb0033_I05.AnaID and tb0033_I05.AnaTypeID ='I05' 

GO